package com.zwj.mapstruct.entity.mapper;

import com.zwj.mapstruct.entity.dto.PigInfoDto;
import com.zwj.mapstruct.entity.pojo.Person;
import com.zwj.mapstruct.entity.pojo.Pig;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PigInfoMapper {
    //    PigInfoMapper MAPPER = Mappers.getMapper(PigInfoMapper.class);
    @Mappings({
            @Mapping(source = "pig.id", target = "id"),
            @Mapping(source = "pig.name", target = "name"),
            @Mapping(source = "pig.age", target = "age"),
            @Mapping(source = "person.name", target = "personName"),
    })
    PigInfoDto from(Pig pig, Person person);
}
